<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Pulog.Models.Tag>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Tags</h2>

    <table>
        <tr>
            <th></th>
            <th>
                TagID
            </th>
            <th>
                TagName
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                <a id="DeletePost" href="javascript:DeletePost(<%=item.TagID %>)">Delete</a>
            </td>
            <td>
                <%= Html.Encode(item.TagID) %>
            </td>
            <td>
                <%= Html.Encode(item.TagName) %>
            </td>
        </tr>
    
    <% } %>

    </table>


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    function DeletePost(id)
    {
        $.ajax({
            type: "POST",
            data: "id="+id,
            dataType: "json",
            url: "<%=ResolveUrl("~/Admin/DeleteTags/") %>",
            success: function(){
                alert('y');
            },
            eror: function() {
                alert('err');
            },
            complete: function(){
                alert("Complete");
                window.location.reload();
            }
        });
    }
</script>
</asp:Content>

